package com.gitee.srurl.system.controller.dashobard;

import com.gitee.srurl.core.annotation.Login;
import com.gitee.srurl.system.biz.DashboardBiz;
import com.gitee.srurl.system.util.response.R;
import com.gitee.srurl.system.vo.DashboardRecentDataVO;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author zxw
 * @date 2023/5/10 22:58
 */
@RestController
@RequestMapping("dashboard")
@RequiredArgsConstructor
public class DashboardController {

    private final DashboardBiz dashboardBiz;

    /**
     * 查询最近数据
     *
     * @param startDate 查询开始时间
     * @param endDate   查询结束时间
     * @return
     */
    @Login
    @GetMapping("recentData")
    public R<DashboardRecentDataVO> recentData(@DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
                                               @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {

        DashboardRecentDataVO dashboardRecentDataVO = dashboardBiz.recentData(startDate, endDate);
        return R.ok(dashboardRecentDataVO);
    }
}
